<?php

class DefaultController extends Controller
{
	public $REPORT_TYPE_OVERVIEW = 0;
	public $REPORT_TYPE_MONITOR = 1;
	public $REPORT_TYPE_TRANSAKSI_HARIAN = 2;
	public $REPORT_TYPE_RENCANA_ANGGARAN = 3;
	
	public function actionIndex($id=0, $divisi=0)
	{	
		//Check POST
		if (isset($_POST['divisi'])) {
			//Get date and go
			
		}
		
		//create division list
		$division = $this->createDivisionList();
		
		//render
		$this->render('index',array('id'=>$id, 'divisi'=>$divisi, 'division'=>$division));
	}
	
	public function createDivisionList()
	{
		$query = "SELECT * FROM `spm_divisi`";
		$command = Yii::app()->db->createCommand($query);
		$results = $command->query();
		
		//read
		$division = array();
		$division[] = "ALL";
		
		$index = 1;
		foreach($results as $row) {
			$division[$index] = $row['nama'];
			$index++;
		}
		
		return $division;
	}
}